Imports System.Data.OracleClient
Imports System.IO
Imports System.Data.Common

Module modDBMain

  Public con As OracleConnection
  Private mStrUserName As String = String.Empty
  Private mStrDSN As String = String.Empty
  Private mStrPassword As String = String.Empty
  Private mStrConnString As String = String.Empty

  Property mPrpUserName() As String
    Get
      Return mStrUserName
    End Get
    Set(ByVal value As String)
      mStrUserName = value
    End Set
  End Property

  Property mPrpPassword() As String
    Get
      Return mStrPassword
    End Get
    Set(ByVal value As String)
      mStrPassword = value
    End Set
  End Property

  Property mPrpDatabase() As String
    Get
      Return mStrDSN
    End Get
    Set(ByVal value As String)
      mStrDSN = value
    End Set
  End Property

  Property mPrpConnString() As String
    Get
      Return mStrConnString
    End Get
    Set(ByVal value As String)
      mStrConnString = value
    End Set
  End Property

  Public Function DBConnect() As Boolean
    con = New OracleConnection

    Try

      If con.State <> ConnectionState.Open Then
        con.ConnectionString = mStrConnString
        con.Open()
      End If
      Return True
    Catch ex As Exception
      MsgBox("Can not connect database", MsgBoxStyle.Exclamation, gCONST_MSG_HEADER)
      Return False
    End Try
  End Function

  Public Function DBDisconnect() As Boolean
    Try

      If con.State = ConnectionState.Open Then
        con.Close()
      End If
      Return True
    Catch ex As Exception
      MsgBox("Can not disconnect database", MsgBoxStyle.Exclamation, gCONST_MSG_HEADER)
      Return False
    End Try
  End Function

  Public Function mPrRefreshConn() As Boolean
    Try

      If con.State <> ConnectionState.Open Then
        'con = New OracleConnection(mStrConnString)
        con.Open()
      End If
      Return True
    Catch ex As Exception
      MsgBox("Can not connect database", MsgBoxStyle.Exclamation, gCONST_MSG_HEADER)
      Return False
    End Try
  End Function

End Module
